import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:random_lottery_ticket/dbutil.dart';
// ignore: must_be_immutable
class RandomSSQDialog extends Dialog{
  List<String> dataList;

  RandomSSQDialog(List<String> dataList){
    this.dataList = dataList;
  }
  @override
  Widget build(BuildContext context) {
    num count = dataList.length/7;
    int itemCount = count.ceil();
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              alignment: Alignment.center,
              decoration: new BoxDecoration(
                color: Colors.white,
                borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
              ),
              height: ScreenUtil().setHeight(700),
              child:ListView.builder(
                  itemCount: itemCount,
                  itemBuilder: (BuildContext ctx, int index) {
                    var reslut = dataList.sublist(index*7,(index+1)*7);
                    return Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        FlatButton(
                          child: Text(
                            reslut[0],
                            maxLines: 2,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[1],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[2],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[3],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[4],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[5],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[6],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.blue,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.blue,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.blue,
                            ),
                          ),
                        ),
                      ],
                    );
                  }
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                IconButton(
                    icon: Icon(Icons.save_alt_outlined),
                    color: Colors.white,
                    iconSize: 30,
                    onPressed: (){
                      int time = new DateTime.now().microsecondsSinceEpoch;
                      RandomData randomdata = new RandomData(time,"0",dataList.toString());
                      DBUtil.insertRandomdata(randomdata);
                      Navigator.of(context).pop();
                    }),
                IconButton(
                    icon: Icon(Icons.clear),
                    color: Colors.white,
                    iconSize: 30,
                    onPressed: (){
                      Navigator.of(context).pop();
                    }),
              ],
            )

          ],
        ),
      ),
    );
  }
}

class RandomSSQRecordsDialog extends Dialog{
  List<String> dataList;

  RandomSSQRecordsDialog(List<String> dataList){
    this.dataList = dataList;
  }
  @override
  Widget build(BuildContext context) {
    num count = dataList.length/7;
    int itemCount = count.ceil();
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              alignment: Alignment.center,
              decoration: new BoxDecoration(
                color: Colors.blueGrey,
                borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
              ),
              height: ScreenUtil().setHeight(700),
              child:ListView.builder(
                  itemCount: itemCount,
                  itemBuilder: (BuildContext ctx, int index) {
                    var reslut = dataList.sublist(index*7,(index+1)*7);
                    return Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        FlatButton(
                          child: Text(
                            reslut[0],
                            maxLines: 2,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[1],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[2],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[3],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[4],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[5],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[6],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.blue,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.blue,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.blue,
                            ),
                          ),
                        ),
                      ],
                    );
                  }
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                IconButton(
                    icon: Icon(Icons.clear),
                    color: Colors.white,
                    iconSize: 30,
                    onPressed: (){
                      Navigator.of(context).pop();
                    }),
              ],
            )

          ],
        ),
      ),
    );
  }
}
class RandomDLTDialog extends Dialog{
  List<String> dataList;

  RandomDLTDialog(List<String> dataList){
    this.dataList = dataList;
  }
  @override
  Widget build(BuildContext context) {
    num count = dataList.length/7;
    int itemCount = count.ceil();
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              alignment: Alignment.center,
              decoration: new BoxDecoration(
                color: Colors.white,
                borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
              ),
              height: ScreenUtil().setHeight(700),
              child:ListView.builder(
                  itemCount: itemCount,
                  itemBuilder: (BuildContext ctx, int index) {
                    var reslut = dataList.sublist(index*7,(index+1)*7);
                    return Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        FlatButton(
                          child: Text(
                            reslut[0],
                            maxLines: 2,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[1],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[2],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[3],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[4],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                         FlatButton(
                          child: Text(
                            reslut[5],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.blue,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.blue,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.blue,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[6],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.blue,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.blue,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.blue,
                            ),
                          ),
                        ),
                      ],
                    );
                  }
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                IconButton(
                    icon: Icon(Icons.save_alt_outlined),
                    color: Colors.white,
                    iconSize: 30,
                    onPressed: (){
                      int time = new DateTime.now().microsecondsSinceEpoch;
                      RandomData randomdata = new RandomData(time,"1",dataList.toString());
                      DBUtil.insertRandomdata(randomdata);
                      Navigator.of(context).pop();
                    }),
                IconButton(
                    icon: Icon(Icons.clear),
                    color: Colors.white,
                    iconSize: 30,
                    onPressed: (){
                      Navigator.of(context).pop();
                    }),
              ],
            )

          ],
        ),
      ),
    );
  }
}
class RandomDLTRecordDialog extends Dialog{
  List<String> dataList;

  RandomDLTRecordDialog(List<String> dataList){
    this.dataList = dataList;
  }
  @override
  Widget build(BuildContext context) {
    num count = dataList.length/7;
    int itemCount = count.ceil();
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              alignment: Alignment.center,
              decoration: new BoxDecoration(
                color: Colors.blueGrey,
                borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
              ),
              height: ScreenUtil().setHeight(700),
              child:ListView.builder(
                  itemCount: itemCount,
                  itemBuilder: (BuildContext ctx, int index) {
                    var reslut = dataList.sublist(index*7,(index+1)*7);
                    return Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        FlatButton(
                          child: Text(
                            reslut[0],
                            maxLines: 2,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[1],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[2],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[3],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[4],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.red,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.red,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.red,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[5],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.blue,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.blue,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.blue,
                            ),
                          ),
                        ),
                        FlatButton(
                          child: Text(
                            reslut[6],
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: ScreenUtil().setSp(48),
                                fontWeight: FontWeight.bold),
                          ),
                          color: Colors.blue,
                          minWidth: ScreenUtil().setWidth(10),
                          textColor: Colors.white,
                          disabledColor: Colors.blue,
                          shape: CircleBorder(
                            side: BorderSide(
                              color: Colors.blue,
                            ),
                          ),
                        ),
                      ],
                    );
                  }
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                IconButton(
                    icon: Icon(Icons.clear),
                    color: Colors.white,
                    iconSize: 30,
                    onPressed: (){
                      Navigator.of(context).pop();
                    }),
              ],
            )

          ],
        ),
      ),
    );
  }
}

